public class Solve {
    // 把数字翻译成字符串
    // https://www.nowcoder.com/practice/046a55e6cd274cffb88fc32dba695668?tpId=295&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%3FquestionJobId%3D10%26subTabName%3Donline_coding_page

    public int solve (String nums) {
        // write code here
        nums = "00" + nums;
        char[] c = nums.toCharArray();
        // dp[i]表示以第i个位置为结尾的字符串有多少种编码结果
        int[] dp = new int[c.length];
        dp[0] = dp[1] = 1;
        for (int i = 2; i < c.length; i++) {
            if (c[i] >= '1' && c[i] <= '9') {
                dp[i] = dp[i-1];
            }
            int tmp = (c[i-1]-'0') * 10 + c[i] - '0';
            if (tmp >= 10 && tmp <= 26) {
                dp[i] += dp[i-2];
            }
        }
        return dp[c.length-1];
    }

    public static void main(String[] args) {
        Solve s = new Solve();
        System.out.println(s.solve("31717126241541717"));
    }
}
